home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / necko / nsIStreamConverter.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  184 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIStreamConverter.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIStreamConverter_h__
  6. #define __gen_nsIStreamConverter_h__
  7.  
  8.  
  9. #ifndef __gen_nsIStreamListener_h__
  10. #include "nsIStreamListener.h"
  11. #endif
  12.  
  13. #ifndef __gen_nsIInputStream_h__
  14. #include "nsIInputStream.h"
  15. #endif
  16.  
  17. #ifndef __gen_nsIURI_h__
  18. #include "nsIURI.h"
  19. #endif
  20.  
  21. /* For IDL files that don't want to include root IDL files. */
  22. #ifndef NS_NO_VTABLE
  23. #define NS_NO_VTABLE
  24. #endif
  25.  
  26. /* starting interface:    nsIStreamConverter */
  27. #define NS_ISTREAMCONVERTER_IID_STR "0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b"
  28.  
  29. #define NS_ISTREAMCONVERTER_IID \
  30.   {0x0b6e2c69, 0x5cf5, 0x48b0, \
  31.     { 0x9d, 0xfd, 0xc9, 0x59, 0x50, 0xe2, 0xcc, 0x7b }}
  32.  
  33. /**
  34.  * nsIStreamConverter provides an interface to implement when you have code
  35.  * that converts data from one type to another.
  36.  *
  37.  * Suppose you had code that converted plain text into HTML. You could implement
  38.  * this interface to allow everyone else to use your conversion logic using a 
  39.  * standard api.
  40.  * <p>
  41.  * <b>STREAM CONVERTER USERS</b>
  42.  *
  43.  * There are currently two ways to use a stream converter:
  44.  * <ol>
  45.  * <li> <b>SYNCHRONOUS</b> Stream to Stream
  46.  *    You can supply the service with a stream of type X
  47.  *    and it will convert it to your desired output type and return
  48.  *    a converted (blocking) stream to you.</li>
  49.  *
  50.  * <li> <b>ASYNCHRONOUS</b> nsIStreamListener to nsIStreamListener
  51.  *    You can supply data directly to the converter by calling it's
  52.  *    nsIStreamListener::OnDataAvailable() method. It will then
  53.  *    convert that data from type X to your desired output type and
  54.  *    return converted data to you via the nsIStreamListener you passed
  55.  *    in by calling its OnDataAvailable() method.</li>
  56.  * </ol>
  57.  * <p>
  58.  *
  59.  * <b>STREAM CONVERTER SUPPLIERS</b>
  60.  *
  61.  * Registering a stream converter:
  62.  * Stream converter registration is a two step process. First of all the stream
  63.  * converter implementation must register itself with the component manager using
  64.  * a contractid in the format below. Second, the stream converter must add the contractid
  65.  * to the registry.
  66.  *
  67.  * Stream converter contractid format (the stream converter root key is defined in this
  68.  * file):
  69.  *
  70.  * <pre>@mozilla.org/streamconv;1?from=FROM_MIME_TYPE&to=TO_MIME_TYPE</pre>
  71.  *
  72.  * @author Jud Valeski
  73.  * @see nsIStreamConverterService
  74.  */
  75. class NS_NO_VTABLE nsIStreamConverter : public nsIStreamListener {
  76.  public: 
  77.  
  78.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISTREAMCONVERTER_IID)
  79.  
  80.   /**
  81.      * <b>SYNCRONOUS VERSION</b>
  82.      * Converts a stream of one type, to a stream of another type.
  83.      *
  84.      * Use this method when you have a stream you want to convert.
  85.      *
  86.      * @param aFromStream   The stream representing the original/raw data.
  87.      * @param aFromType     The MIME type of aFromStream.
  88.      * @param aToType       The MIME type of the returned stream.
  89.      * @param aCtxt         Either an opaque context, or a converter specific context
  90.      *                      (implementation specific).
  91.      * @return              The converted stream. NOTE: The returned stream may not
  92.      *                      already be converted. An efficient stream converter
  93.      *                      implementation will converter data on demand rather than
  94.      *                      buffering the converted data until it is used.
  95.      */
  96.   /* nsIInputStream convert (in nsIInputStream aFromStream, in string aFromType, in string aToType, in nsISupports aCtxt); */
  97.   NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval) = 0;
  98.  
  99.   /**
  100.      * <b>ASYNCRONOUS VERSION</b>
  101.      * Converts data arriving via the converter's nsIStreamListener::OnDataAvailable() 
  102.      * method from one type to another, pushing the converted data out to the caller 
  103.      * via aListener::OnDataAvailable().
  104.      *
  105.      * Use this method when you want to proxy (and convert) nsIStreamListener callbacks
  106.      * asynchronously.
  107.      *
  108.      * @param aFromType     The MIME type of the original/raw data.
  109.      * @param aToType       The MIME type of the converted data.
  110.      * @param aListener     The listener who receives the converted data.
  111.      * @param aCtxt         Either an opaque context, or a converter specific context
  112.      *                      (implementation specific).
  113.      */
  114.   /* void asyncConvertData (in string aFromType, in string aToType, in nsIStreamListener aListener, in nsISupports aCtxt); */
  115.   NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt) = 0;
  116.  
  117. };
  118.  
  119. /* Use this macro when declaring classes that implement this interface. */
  120. #define NS_DECL_NSISTREAMCONVERTER \
  121.   NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval); \
  122.   NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt); 
  123.  
  124. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  125. #define NS_FORWARD_NSISTREAMCONVERTER(_to) \
  126.   NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval) { return _to Convert(aFromStream, aFromType, aToType, aCtxt, _retval); } \
  127.   NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt) { return _to AsyncConvertData(aFromType, aToType, aListener, aCtxt); } 
  128.  
  129. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  130. #define NS_FORWARD_SAFE_NSISTREAMCONVERTER(_to) \
  131.   NS_IMETHOD Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Convert(aFromStream, aFromType, aToType, aCtxt, _retval); } \
  132.   NS_IMETHOD AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt) { return !_to ? NS_ERROR_NULL_POINTER : _to->AsyncConvertData(aFromType, aToType, aListener, aCtxt); } 
  133.  
  134. #if 0
  135. /* Use the code below as a template for the implementation class for this interface. */
  136.  
  137. /* Header file */
  138. class nsStreamConverter : public nsIStreamConverter
  139. {
  140. public:
  141.   NS_DECL_ISUPPORTS
  142.   NS_DECL_NSISTREAMCONVERTER
  143.  
  144.   nsStreamConverter();
  145.  
  146. private:
  147.   ~nsStreamConverter();
  148.  
  149. protected:
  150.   /* additional members */
  151. };
  152.  
  153. /* Implementation file */
  154. NS_IMPL_ISUPPORTS1(nsStreamConverter, nsIStreamConverter)
  155.  
  156. nsStreamConverter::nsStreamConverter()
  157. {
  158.   /* member initializers and constructor code */
  159. }
  160.  
  161. nsStreamConverter::~nsStreamConverter()
  162. {
  163.   /* destructor code */
  164. }
  165.  
  166. /* nsIInputStream convert (in nsIInputStream aFromStream, in string aFromType, in string aToType, in nsISupports aCtxt); */
  167. NS_IMETHODIMP nsStreamConverter::Convert(nsIInputStream *aFromStream, const char *aFromType, const char *aToType, nsISupports *aCtxt, nsIInputStream **_retval)
  168. {
  169.     return NS_ERROR_NOT_IMPLEMENTED;
  170. }
  171.  
  172. /* void asyncConvertData (in string aFromType, in string aToType, in nsIStreamListener aListener, in nsISupports aCtxt); */
  173. NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const char *aFromType, const char *aToType, nsIStreamListener *aListener, nsISupports *aCtxt)
  174. {
  175.     return NS_ERROR_NOT_IMPLEMENTED;
  176. }
  177.  
  178. /* End of implementation class template. */
  179. #endif
  180.  
  181. #define NS_ISTREAMCONVERTER_KEY         "@mozilla.org/streamconv;1"
  182.  
  183. #endif /* __gen_nsIStreamConverter_h__ */
  184.